﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib">
    
    <Duration x:Key="RotateDuration">0:0:.2</Duration>
    <Duration x:Key="OpacityDuration">0:0:.2</Duration>
    <Duration x:Key="ExpandDuration">0:0:.2</Duration>
    <!--<System:Double x:Key="To">70.92</System:Double>-->


    <Style x:Key="Arrow" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid SnapsToDevicePixels="False" Background="Transparent">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="19"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Ellipse x:Name="circle" Stroke="DarkGray" HorizontalAlignment="Center" VerticalAlignment="Center" Width="19" Height="19"/>
                            <Path x:Name="arrow" Stroke="#666" StrokeThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin=".5,.5" SnapsToDevicePixels="false" Data="M 1,1.5 L 4.5,5 L 8,1.5">
                                <Path.RenderTransform>
                                    <RotateTransform/>
                                </Path.RenderTransform>
                            </Path>
                            <ContentPresenter HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" SnapsToDevicePixels="True" Grid.Column="1" RecognizesAccessKey="True"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="ToggleButton.Checked">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="arrow" To="-180" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" Duration="{StaticResource RotateDuration}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="ToggleButton.Unchecked">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="arrow" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" Duration="{StaticResource RotateDuration}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Expander}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <DockPanel>
                        <ToggleButton Style="{StaticResource Arrow}" Margin="1" MinHeight="0" MinWidth="0" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top"/>
                        <ContentPresenter x:Name="PART_ExpandSite" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Focusable="false" Opacity="0" DockPanel.Dock="Bottom">
                            <ContentPresenter.LayoutTransform>
                                <ScaleTransform ScaleY="0"/>
                            </ContentPresenter.LayoutTransform>
                            <!--<ContentPresenter.Effect>
                                <BlurEffect KernelType="Gaussian" Radius="5"/>
                            </ContentPresenter.Effect>-->
                        </ContentPresenter>
                        <!--<TextBlock Text="{Binding ElementName=PART_ExpandSite, Path=ActualHeight}"></TextBlock>-->
                    </DockPanel>
                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="Expander.Expanded">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="PART_ExpandSite" Storyboard.TargetProperty="Opacity" To="1" Duration="{StaticResource OpacityDuration}"/>
                                    <!--<DoubleAnimation Storyboard.TargetName="PART_ExpandSite" Storyboard.TargetProperty="(UIElement.Effect).(BlurEffect.Radius)" To="0" Duration="{StaticResource OpacityDuration}"/>-->
                                    <!--<DoubleAnimation Storyboard.TargetName="PART_ExpandSite" Storyboard.TargetProperty="Height" To="{StaticResource To}" Duration="{StaticResource ExpandDuration}"/>-->
                                    <DoubleAnimation Storyboard.TargetName="PART_ExpandSite" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleY)" To="1" Duration="{StaticResource ExpandDuration}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="Expander.Collapsed">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="PART_ExpandSite" Storyboard.TargetProperty="Opacity" To="0" Duration="{StaticResource OpacityDuration}"/>
                                    <!--<DoubleAnimation Storyboard.TargetName="PART_ExpandSite" Storyboard.TargetProperty="(UIElement.Effect).(BlurEffect.Radius)" To="5" Duration="{StaticResource OpacityDuration}"/>-->
                                    <!--<DoubleAnimation Storyboard.TargetName="PART_ExpandSite" Storyboard.TargetProperty="Height" To="0" Duration="{StaticResource ExpandDuration}"/>-->
                                    <DoubleAnimation Storyboard.TargetName="PART_ExpandSite" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleY)" To="0" Duration="{StaticResource ExpandDuration}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>